home *** CD-ROM | disk | FTP | other *** search
Modula Implementation | 1988-10-02 | 7.5 KB | 241 lines |
-
-
- IMPLEMENTATION MODULE supertest;
-
-
- FROM RandomNumbers IMPORT Seed,Random;
- FROM InOut IMPORT WriteLn,WriteString,ReadString,WriteInt,WriteCard;
- FROM Strings IMPORT String,Length,Concat;
- FROM SYSTEM IMPORT ADDRESS,WORD,NULL,ADR;
- IMPORT Terminal; (* conflict with DOSFiles.Write *)
- FROM Pens IMPORT SetAPen,SetDrMd,Move;
- FROM Text IMPORT Text;
- FROM myscreen IMPORT RP, ourwindow;
- FROM mtest IMPORT HexChar,Convert,ConvertChar, WriteHex;
- FROM mdraw IMPORT drawpixel,drawstats,addressbits,databits;
- FROM Rasters IMPORT ScrollRaster;
- FROM Intuition IMPORT IntuiMessagePtr, IDCMPFlags, IDCMPFlagSet,
- SelectDown, MenuDown;
- FROM Ports IMPORT GetMsg, ReplyMsg, MessagePtr, WaitPort;
- FROM DOSFiles IMPORT Open,Close,Write,FileHandle,ModeNewFile;
-
-
- VAR j,maxvalue,redcard,valuecard:CARDINAL;
- addresscard : LONGCARD;
- response, stringA, stringB, endofline:String;
- i,errorlimit:INTEGER;
- start,end:ADDRESS;
- startmessage,endmessage : String;
- mesg : IntuiMessagePtr;
- actual : LONGINT;
- myfile : FileHandle;
- bitarray : ARRAY[0..15] OF WORD;
- class : IDCMPFlagSet;
- code,bit : CARDINAL;
-
- PROCEDURE DoSuperBits(start,end:ADDRESS;
- errorlimit:INTEGER;
- save,dowrite,message:BOOLEAN);
-
- VAR i:ADDRESS;
- value:WORD;
- errors:INTEGER;
- quit, currenterror:BOOLEAN;
-
- BEGIN
- SetAPen(RP,4);
- Move(RP,30,280);
- Text(RP,startmessage,16);
-
- FOR j := 0 TO 23 DO
- addressbits[j] := 0;
- END; (* for *)
-
- FOR j := 0 TO 15 DO
- databits[j] := 0;
- END; (* for *)
-
- IF save THEN
- myfile := Open('ramerr',ModeNewFile);
- END; (* if *);
-
- mesg:=IntuiMessagePtr(GetMsg(ourwindow^.UserPort));
- WHILE mesg#NULL DO
- mesg:=IntuiMessagePtr(GetMsg(ourwindow^.UserPort));
- END; (* while *)
-
- SetAPen(RP,2); (* blue *)
- ScrollRaster(RP,0,10,0,300,639,399);
- ScrollRaster(RP,0,10,0,300,639,399);
- ScrollRaster(RP,0,10,0,300,639,399);
- ScrollRaster(RP,0,10,0,300,639,399);
- ScrollRaster(RP,0,10,0,300,639,399);
- Move(RP,20,370);
- Text(RP,
- ' --------- CLICK LEFT MOUSE BUTTON TO STOP --------- ',
- 50);
- Move(RP,20,380);
- Text(RP,
- ' --------- HOLD RIGHT MOUSE BUTTON TO PAUSE -------- ',
- 50);
-
- i:=start;
- drawpixel(i,6);
- errors:=0;
- quit:=FALSE;
- currenterror:=FALSE;
- WHILE (i<=end) AND (errors<errorlimit) AND NOT quit DO
- bit:= 0;
- LOOP
- IF (bit>15) OR quit THEN
- EXIT;
- END; (* if *)
- i^:=bitarray[bit];
-
- value:=WORD(i^);
- IF CARDINAL(value) # CARDINAL(bitarray[bit]) THEN
- currenterror:=TRUE;
- IF save OR message THEN
- stringA := 'BAD Location, address - ';
-
- WriteHex(CARDINAL(i DIV 65536),stringA,stringB);
- WriteHex(CARDINAL(i MOD 65536),stringB,stringA);
-
- Concat(stringA,'H Written - ',stringB);
-
- WriteHex(CARDINAL(bitarray[bit]),stringB,stringA);
-
- Concat(stringA,'H Read - ',stringB);
-
- WriteHex(CARDINAL(value),stringB,stringA);
-
- Concat(stringA,'H',stringB);
- END; (* if *)
-
- IF message THEN
- SetAPen(RP,3);
- ScrollRaster(RP,0,10,0,300,639,399);
- Move(RP,20,380);
- Text(RP,stringB,Length(stringB));
- END; (* if *)
-
- IF save AND (myfile<>LONGCARD(0)) THEN
- Concat(stringB,endofline,stringA);
- actual := Write(myfile,ADR(stringA),LONGCARD(Length(stringA)));
- END; (* if *)
-
- INC(errors);
-
- drawpixel(i,3);
-
- (* WriteString('mark 1');
- WriteLn;*)
-
- addresscard := LONGCARD(i);
- FOR j:= 0 TO 23 DO
- IF addresscard MOD 2 > 0 THEN
- INC(addressbits[j]);
- END; (* if *)
- addresscard := addresscard DIV 2;
- END; (* for *)
-
- valuecard := CARDINAL(i DIV 2);
- redcard := CARDINAL(value);
-
- FOR j:= 0 TO 15 DO
- IF (valuecard MOD 2) # (redcard MOD 2) THEN
- INC(databits[j]);
- END; (* if *)
- valuecard := valuecard DIV 2;
- redcard := redcard DIV 2;
- END; (* for *)
-
- (* WriteString('mark 2');
- WriteLn;*)
-
- mesg:=IntuiMessagePtr(GetMsg(ourwindow^.UserPort));
- IF mesg # NULL THEN (* user wants to quit *)
- class:=mesg^.Class;
- code :=mesg^.Code;
-
- (* WriteString('mark 3');
- WriteLn;*)
-
- IF IDCMPFlags(MouseButtons) IN class THEN
- IF SelectDown = code THEN
- (* WriteString('Selectdown detected and replied');
- WriteLn;*)
- ReplyMsg(MessagePtr(mesg));
- quit:=TRUE;
- SetAPen(RP,2); (* blue *)
- ScrollRaster(RP,0,10,0,300,639,399);
- Move(RP,20,380);
- Text(RP,
- ' -------- OPERATION ABORTED BY USER -------- ',
- 50);
- ELSIF MenuDown = code THEN
- (* WriteString('MenuDown detected and replied');
- WriteLn;*)
- ReplyMsg(MessagePtr(mesg));
- mesg:=IntuiMessagePtr(WaitPort(ourwindow^.UserPort));
- WHILE mesg # NULL DO
- mesg:=IntuiMessagePtr(GetMsg(ourwindow^.UserPort));
- END; (* while *)
- END; (* elsif *)
- ELSE
- ReplyMsg(MessagePtr(mesg));
- (* WriteString('Non mouse message recieved and replied');
- WriteLn;*)
- END; (* else *)
-
- END; (* if received intuimessage *)
-
- END; (* if not same then *)
-
- INC(bit,1);
- END; (* loop from bit 0 to 15 *)
-
- INC(i,2);
- IF i MOD 65536 = 0 THEN
- drawpixel(i,6);
- IF currenterror THEN
- drawpixel(ADDRESS(LONGCARD(i)-10),2);
- currenterror:=FALSE;
- END; (* if *)
- mesg:=IntuiMessagePtr(GetMsg(ourwindow^.UserPort));
- IF mesg#NULL THEN (* user wants to quit *)
- ReplyMsg(MessagePtr(mesg));
- quit := TRUE;
- END; (* if *)
- END; (* if *)
-
- END; (* while not quit and still in range *)
-
- IF save AND (myfile<>LONGCARD(0)) THEN
- Close(myfile);
- END; (* if *)
-
- drawstats;
-
- SetAPen(RP,4);
- Move(RP,30,280);
- Text(RP,endmessage,16);
- END DoSuperBits;
-
-
-
-
- BEGIN (* memorytest *)
- startmessage := 'Doing Test Now...';
- endmessage := 'Test Completed. ';
- endofline[0] := CHR(10);
- endofline[1] := CHR(0);
-
- bitarray[0] := WORD(1);
- FOR j:=1 TO 15 DO
- bitarray[j]:=WORD(CARDINAL(bitarray[j-1])*2);
- END; (* for *);
-
- END supertest.
-
-